List all terrains from DGN
The terrain
surfaces are part of the Geometric model of a dgn. To get all terrain surfaces
with the terrain model from current dgn file, the below code snippet shows how
this can be achieved.
Example
//Required SDK Libraries
using System.Collections.Generic;
using Bentley.DgnPlatformNET;
using Bentley.CifNET.GeometryModel.SDK;
using Bentley.CifNET.SDK;
internal void ListAllTerrainsFromDgn()
{
//Get active dgn model
Bentley.DgnPlatformNET.DgnModel activeModel = Bentley.MstnPlatformNET.Session.Instance.GetActiveDgnModel();
//Get connection
Bentley.CifNET.SDK.ConsensusConnection con = new Bentley.CifNET.SDK.ConsensusConnection(activeModel);
//Get geometric model
Bentley.CifNET.GeometryModel.SDK.GeometricModel geomModel = con.GetActiveGeometricModel();
if (geomModel == null) return;
//Get all terrain surfaces from Geometric model
IEnumerable<TerrainSurface> allTerrainSurfaces = geomModel.TerrainSurfaces;
//Iterate over each terrain surface to get DTM
foreach (TerrainSurface terrainSurface in allTerrainSurfaces)
{
//Get terrain model from terrain surface
DTM dTM = terrainSurface.DTM;
}
}
Get TerrainSurfaces from GeometricModel to get all terrains.